/*
 * ======================================================================
 *
 *       Filename:  find.h
 *
 *       Version:  1.0
 *       Created:  10/04/2011 02:42:23 PM
 *       Compiler:  gcc
 *
 *       Author:  durand_y, <yoan.durand@gmail.com>
 *
 * =======================================================================
 */
#ifndef FIND_H_
# define FIND_H_

# include <features.h>
# define _GNU_SOURCE
# include <sys/types.h>
# include <sys/stat.h>
# include <sys/time.h>
# include <fcntl.h>
# include <dirent.h>
# include "tools.h"
# include "list.h"

/*
* Define the number of second in one day
*
*/
# define SEC_IN_DAY         (86400)

/*
* Print the HELP of the project
*/
void    usage(char          *str);

/*
* fill up list with all directories in path
*/
void    listdir(char        *path,
                s_list      *list);
/*
* test if a directory or a file can be opened
*/
int     permission(char     *path);

/*
*  call the function name
*/
int     name(s_list         **list,
             char           *elt,
             int            end);


/*
* call the option newer
*/
int     newer(s_list        **list,
              char          *file,
              int           end);


/*
* call the option atime
*/
int     atime(s_list        **list,
              int           time,
              int           end);

/*
* Print perror
*/
void    my_error(char       *bin,
                 char       *error);

/*
* Other errors
*/
void    my_error2(char      *bin,
                  char      *err,
                  int       type);

/*
* First function or execution
*/
int     exec1(int           *i,
              char          **argv,
              int           *argc,
              s_list        *list,
              s_list        *dirlist);

/*
* test if the next element of the list is null
*/
int     test_next(s_list    *l);

/*
* execute name
*/
s_list  *exec_name(s_list   *list_op,
                   s_list    **list);

/*
* execute newer
*/
s_list  *exec_newer(s_list  *list_op,
                    s_list  **list);

/*
* execute atime
*/
s_list  *exec_atime(s_list  *list_op,
                    s_list  **list);

/*
* execute error
*/
void    exec_error(char     *s,
                   char     *str);
/*
* execute help
*/
void    exec_help(char      *s);

/*
* parse short option
*/
void    parse_short(int     *argc,
                    int     *i,
                    char    **tab);

#endif /* !FIND_H_ */
